home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wics.zip
/
IDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-03
|
4KB
|
150 lines
//==============================================================================================
//
// Windows Interface Construction Set
// Version 1.00
//
// IDLG.CPP - Indirect Dialog Class Source File
// Copyright ⌐ 1993 by Microdyne Development Technologies.
// All rights reserved.
//==============================================================================================
#include <idlg.h>
extern PTWindowsObject DlgCreationWindow;
/*------------------------------------------------------------------------------------------*/
/* Class TIndirectDialog */
/*------------------------------------------------------------------------------------------*/
/* */
/* Abstract: */
/* */
/* The TIndirectDialog class defines an indirect dialog object. The dialog template is */
/* built in memory utilizing the TDialogTemplate object and then passed to this class */
/* creates the dialog based upon this template. */
/* */
/*------------------------------------------------------------------------------------------*/
static BOOL RegFails(void *AWindowsObject, void *)
{
return !((PTWindowsObject)AWindowsObject)->Register();
}
TIndirectDialog::TIndirectDialog(PTWindowsObject AParent, PTDialogTemplate pdt)
: TDialog(AParent, 0)
{
ADialogTemplate = pdt;
}
TIndirectDialog::~TIndirectDialog()
{
if ( !IsModal )
GlobalUnlock (ADialogTemplate->GetHandle());
delete ADialogTemplate;
}
/* Creates an MS-Windows modeless dialog, and associates the modeless dialog interface
element with the TIndirectDialog. Creation and association are not attempted if the Status
data member is non-zero.
*/
BOOL TIndirectDialog::Create()
{
HWND HParent;
IsModal = FALSE; // GetClassName called from Register needs to know this.
if ( Status == 0 && Register() )
{
DisableAutoCreate();
EnableKBHandler();
if ( !Parent )
HParent = 0;
else
HParent = Parent->HWindow;
DlgCreationWindow = this;
/* Register all the dialog's child objects (for custom control support) */
if ( FirstThat(RegFails, NULL) == NULL )
{
lpDialog = (LPDIALOGBOXHEADER) GlobalLock (ADialogTemplate->GetHandle()) ;
HWindow = CreateDialogIndirectParam(GetModule()->hInstance, lpDialog, HParent, (DLGPROC)GetInstance(), Attr.Param);
if ( !HWindow )
Status = EM_INVALIDWINDOW;
}
else
Status = EM_INVALIDCHILD;
DlgCreationWindow = NULL;
}
return (Status == 0);
}
/* Creates an MS-Windows modal dialog. Associates the modal dialog interface element with
the TIndirectDialog. Creation and association is not attempted if the Status data member is
non-zero.
*/
int TIndirectDialog::Execute()
{
HWND HParent;
int ReturnValue = -1;
PTWindowsObject OldKBHandler;
IsModal = TRUE;
if ( Status == 0 && Register() )
{
DisableAutoCreate();
/* Enable the keyboard handler. Although modal dialogs do their own keyboard
handling, we use the WB_KBHANDLER flag for WM_COMMAND processing.
*/
EnableKBHandler();
if ( GetApplication() )
OldKBHandler = GetApplication()->KBHandlerWnd;
if ( !Parent )
HParent = 0;
else
HParent = Parent->HWindow;
DlgCreationWindow = this;
/* Register all the dialog's child objects (for custom control support) */
if ( FirstThat(RegFails, NULL) == NULL )
{
ReturnValue = DialogBoxIndirectParam(GetModule()->hInstance, ADialogTemplate->GetHandle(), HParent, (DLGPROC)GetInstance(), Attr.Param);
// -1 if the function cannot create the dialog box
if ( ReturnValue == -1)
Status = EM_INVALIDWINDOW;
}
else
Status = EM_INVALIDCHILD;
DlgCreationWindow = NULL;
if ( GetApplication() )
GetApplication()->SetKBHandler(OldKBHandler);
}
if ( Status == 0 )
delete this;
else
if (ReturnValue != -1)
ReturnValue = BAD_DIALOG_STATUS; // dialog ran, but status != 0
return ReturnValue;
}